package com.web.kdl.util;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.web.kdl.entity.matrix.Matrix;
import com.web.kdl.entity.site.Site;
import com.web.kdl.service.createTable.TableDataType;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author： shulibin
 * @Date： 2025/7/29 14:46
 * @Describe：
 */
public class TableNameUtils {
    private static final String PREFIX_ALERT = "wheel_alert";
    private static final String PREFIX_DATA = "wheel_data";
    private static final String PREFIX_STATUS = "wheel_status";
    private static final String GENERAL_CONTROL = "general_control";
    private static final String COMMON ="flywheel";

    public static String getAlertTableName(String siteName,String matrix,int flywheelSerial) {
        return PREFIX_ALERT +"_"+ siteName +"_"+matrix+"_"+ COMMON+flywheelSerial;
    }
    public static String getDataTableName(String siteName,String matrix,int flywheelSerial,TableDataType type) {
        return PREFIX_DATA +"_" + type.name().toLowerCase() + "_"+ siteName +"_"+matrix+"_"+ COMMON+flywheelSerial;
    }
    public static String getDataTableName(String siteName,String matrix,String flywheelName,TableDataType type) {
        return PREFIX_DATA +"_" + type.name().toLowerCase() + "_"+ siteName +"_"+matrix+"_"+ flywheelName;
    }
    public static String getStatusTableName(String siteName,String matrix,int flywheelSerial) {
        return PREFIX_STATUS +"_"+ siteName +"_"+matrix+"_"+ COMMON+flywheelSerial;
    }
    public static String getStatusTableName(String siteName,String matrixName,String flyWheelName) {
        return PREFIX_STATUS +"_"+ siteName +"_"+matrixName+"_"+ flyWheelName;
    }
    public static String getAlertTableName(String siteName,String matrixName,String flyWheelName) {
        return PREFIX_ALERT +"_"+ siteName +"_"+matrixName+"_"+ flyWheelName;
    }
    public static String getDataTableName(String siteName,String matrixName,String flyWheelName) {
        return PREFIX_DATA +"_"+ siteName +"_"+matrixName+"_"+ flyWheelName;
    }
    public static String getControlStatusTableName(String siteName,String matrix) {
        return PREFIX_STATUS +"_"+siteName+"_"+ matrix +"_"+ GENERAL_CONTROL;
    }
    public static String getControlAlertTableName(String siteName,String matrix) {
        return PREFIX_ALERT +"_"+siteName+"_"+ matrix +"_"+ GENERAL_CONTROL;
    }
    public static String getControlDataTableName(String siteName,String matrix) {
        return PREFIX_DATA +"_"+siteName+"_"+ matrix +"_"+ GENERAL_CONTROL;
    }

    public static List<String> getAllDataTableName(List<Matrix> matrixList, String siteName,TableDataType  type) {

        List<String> tableNameList = new ArrayList<>();
        matrixList.forEach(matrix -> {
            for (int i = 1; i <= matrix.getWheelNumber(); i++) {
                tableNameList.add(getDataTableName(siteName, matrix.getMatrixName(), i, type));
            }
        });
        return tableNameList;
    }
    public static List<String> getAllStatusTableName(List<Matrix> matrixList, String siteName) {
        List<String> tableNameList = new ArrayList<>();
        matrixList.forEach(matrix -> {
            for (int i = 1; i <= matrix.getWheelNumber(); i++) {
                tableNameList.add(getStatusTableName(siteName, matrix.getMatrixName(), i));
            }
        });
        return tableNameList;
    }
    public static List<String> getAllAlertTableName(List<Matrix> matrixList, String siteName){
        List<String> tableNameList = new ArrayList<>();
        matrixList.forEach(matrix -> {
            for (int i = 1; i <= matrix.getWheelNumber(); i++) {
                tableNameList.add(getAlertTableName(siteName, matrix.getMatrixName(), i));
            }
        });
        return tableNameList;
    }

}
